
cmake_minimum_required(VERSION 3.10)

project(yolov5)

add_definitions(-std=c++11)
add_definitions(-DAPI_EXPORTS)

# 不使用静态链接（动态就是编译出的执行文件不包含cuda，执行时会在系统搜索cuda，执行文件更小）
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)

# CMAKE_CXX_STANDARD是内置变量，用于设定c++版本
set(CMAKE_CXX_STANDARD 11)
# CMAKE_BUILD_TYPE是内置变量，用于设定编译模式
set(CMAKE_BUILD_TYPE Debug)

set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
enable_language(CUDA)

include_directories(/usr/local/cuda/include)
link_directories(/usr/local/cuda/lib64)

# include_directories(/usr/local/TensorRT-7.1.3.4/include/)
# link_directories(/usr/local/TensorRT-7.1.3.4/lib/)

# 插件头文件和源码
include_directories(${PROJECT_SOURCE_DIR}/)
file(GLOB_RECURSE PLUGIN_SRCS ${PROJECT_SOURCE_DIR}/*.cu)

add_library(hardswish SHARED ${PLUGIN_SRCS})
target_link_libraries(hardswish nvinfer cudart)